import tushare as ts


mytoken = "a1c1d8f0b4c6f4b868de2a280d03924eae9b47555b9a7eecc8b1ee5a"

ts.set_token(mytoken)

api = ts.pro_api()
# 定义池子
# pool = ['600580.SH', '002553.SZ', '000678.SZ', '600320.SH', '000610.SZ']
pool = ['000610.SZ']
# 定义日期
start_date = '20240201'
end_date = '20250409'

# 遍历池子，获取每只的日k线数据
for code in pool:
    # 获取日k线数据
    data = api.query('daily',
                    ts_code=code,
                    start_date=start_date,
                    end_date=end_date)
    print(type(data))
    data = data[['ts_code','trade_date', 'open', 'close', 'high', 'low', 'vol']]
    # 将数据保存到tushare_data文件夹下csv文件
    data.to_csv(f'tushare_data/{code}.csv', index=False)
